package com.ruoyi.file.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

@Configuration
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class OssConfig {

    @Bean
    @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public OSS ossClient(){
        // Endpoint以成都为例。
        //创建对象存储的域名
        String endpoint = "oss-cn-shenzhen.aliyuncs.com";
        //验证码获取的accessKeyId
        String accessKeyId = "LTAI5tAA7yhCp2BWtfPmcLHN";
        //验证码获取的accessKeySecret
        String accessKeySecret = "lBclRS7d3mMajrdGj2vWxOUeWnlKpU";
        // 创建OSSClient实例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
        return ossClient;
    }

}